package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {
    // 根据用户名查询数据库
    @Select("select * from employee where username=#{username}")
    Employee getByUsername(String username);

    /**
     * 员工分页查询
     * @param employeePageQueryDTO
     * @return
     */
    List<Employee> findByMapper(EmployeePageQueryDTO employeePageQueryDTO);


    /**
     * 新增员工
     * @param employee
     */
    @Insert("insert into employee values (null,#{name},#{username},#{password},#{phone},#{sex}," +
            "#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill("insert")
    void save(Employee employee);


    /**
     * 回显员工  (id 查询)
     * @param id
     * @return
     */
    @Select("select * from employee where id=#{id}")
    Employee findById(Long id);


    /**
     * 修改员工
     * @param employee
     */
    @AutoFill("update")
    void update(Employee employee);
}
